package Com.Hupochuan.Uil.Do;

import java.util.List;

import Com.Hupochuan.Dal.Tab.FlipPanelTab;
import Com.Hupochuan.Dal.Tab.HotPlayMovieTab;
import Com.Hupochuan.Dal.Tab.MovieTab;
import Com.Hupochuan.Dal.Tab.YouLikeMovieTab;
import Com.Hupochuan.Uil.Servlet.DoRunServlet;
import Com.Hupochuan.Uil.Util.MemoryPond;
import Com.Hupochuan.Vo.Actor;
import Com.Hupochuan.Vo.AreaSort;
import Com.Hupochuan.Vo.Director;
import Com.Hupochuan.Vo.FlipPanel;
import Com.Hupochuan.Vo.HotPlayMovie;
import Com.Hupochuan.Vo.Movie;
import Com.Hupochuan.Vo.Type;
import Com.Hupochuan.Vo.Year;
import Com.Hupochuan.Vo.YouLikeMovie;
import Com.Tester.Tester;

@SuppressWarnings("serial")
public class IndexDo extends DoRunServlet{
	public void doRun(){
		
		//打印测试
		Tester.print("打印测试 - IndexDo");
		
		String htmlContent = MemoryPond.getObject().getIndexHtml();
		
		//如果找到页
		if(htmlContent != null){
			//发送静态页面
			this.getDoTool().sendMsg(htmlContent);
			return;
		}
		
		//获得内存参数
		List<Type> typeList = MemoryPond.getObject().getTypeList();
		List<Year> yearList = MemoryPond.getObject().getYearList();
		List<AreaSort> areaSortList = MemoryPond.getObject().getAreaSortList();
		List<Director> directorList = MemoryPond.getObject().getDirectorList(0,0,0);
		List<Actor> actorList = MemoryPond.getObject().getActorList(0,0,0,0);
		
		//获得数据
		List<FlipPanel> flipPanelList = FlipPanelTab.getObject().findFlipPanelList();
		List<Movie> newMovieTop18List = MovieTab.getObject().findNewMovieTop18List();
		List<HotPlayMovie> hotPlayMovieList = HotPlayMovieTab.getObject().findHotPlayMovieList();
		List<YouLikeMovie> youLikeMovieList = YouLikeMovieTab.getObject().findYouLikeMovieList();
		
		//设置参数
		this.getDoTool().setAttr("typeList", typeList);
		this.getDoTool().setAttr("yearList", yearList);
		this.getDoTool().setAttr("areaSortList", areaSortList);
		this.getDoTool().setAttr("directorList", directorList);
		this.getDoTool().setAttr("actorList", actorList);
		this.getDoTool().setAttr("flipPanelList", flipPanelList);
		this.getDoTool().setAttr("newMovieTop18List", newMovieTop18List);
		this.getDoTool().setAttr("hotPlayMovieList", hotPlayMovieList);
		this.getDoTool().setAttr("youLikeMovieList", youLikeMovieList);
		
		//转发页面
		this.getDoTool().doForward("/jsp/index.jsp");
		
		//获得html内容
		htmlContent = this.getDoTool().htmlEncode(this.getDoTool().getContent());
		
		//发送信息
		this.getDoTool().sendMsg(htmlContent);
		
		//保存页面信息
		MemoryPond.getObject().setIndexHtml(htmlContent);
	}
}
